package cn.genmer.test.security.machinelearning.deeplearning4j.mnist.common;

import cn.genmer.test.security.machinelearning.deeplearning4j.mnist.V1.MnistTrain;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class ReadTextFile {

    public static String readFileAsString(String filePath) throws IOException {
        StringBuilder content = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            String line;
            while ((line = reader.readLine()) != null) {
                content.append(line).append("\n");
            }
        }
        return content.toString();
    }

    public static void main(String[] args) {
        String filePath = MnistTrain.BASE_PATH + "/mnist_png/decompression/25790.txt";
        try {
            String fileContent = readFileAsString(filePath);
            System.out.println(fileContent);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}